package com.gemme.gemme.view;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;

import com.gemme.gemme.util.DpUtil;
import com.gemme.gemme.util.ShapeUtil;

/**
 * @Author: yangcheng
 * @CreateDate: 2020/7/24 10:37
 */
public class MyButton extends androidx.appcompat.widget.AppCompatButton {
    private Context context;

    public MyButton(Context context) {
        this(context,null);
    }

    public MyButton(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MyButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }

    private void initView() {
        setSatate(true);
    }



    public void setSatate(boolean state){
        try {
            setEnabled(state);
            if(state){
//            tv_vip.setBackground(ShapeUtil.getCornBg(DpUtil.dp2px(mContext,9),"#FF403F3F"));
                setBackground(ShapeUtil.getCornBg(DpUtil.dp2px((Activity) context,4),"#ff9d2c2f"));
//                setBackground(ShapeUtil.getCornBg(DpUtil.dp2px((Activity) context,4),"#FFD0D0D0"));
            }else{
                setBackground(ShapeUtil.getCornBg(DpUtil.dp2px((Activity) context,4),"#ffe6e6e6"));
            }
        }catch (Exception e){

        }
    }
}
